package com.zhoutao123.hephaestus.object.bussiness;

import com.zhoutao123.hephaestus.repository.entity.Blog;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.Date;

@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel("文章业务对象")
public class VBlog implements Serializable {

  @ApiModelProperty("文章唯一标识")
  private String id;

  @ApiModelProperty("文章标题")
  private String title;

  @ApiModelProperty("封面URL")
  private String coverImage;


  @ApiModelProperty("文章内容")
  private String content;

  @ApiModelProperty("文章源码")
  private String contentMd;

  @ApiModelProperty("是否置顶")
  private Boolean top;

  @ApiModelProperty("文章类型ID")
  private String typeId;

  @ApiModelProperty("文章状态")
  private Boolean status;

  @ApiModelProperty("是否推荐")
  private Boolean recommended;

  @ApiModelProperty("是否原创")
  private Boolean original;

  @ApiModelProperty("简介(200字)")
  private String description;

  @ApiModelProperty("文章关键字")
  private String keywords;

  @ApiModelProperty("是否开启评论")
  private Boolean comment;

  @ApiModelProperty("创建时间")
  private Date createTime;

  @ApiModelProperty("更新时间")
  private Date updateTime;

  @ApiModelProperty("文章阅读记录")
  private long vBlogLookCount;

  public static VBlog of(Blog bizArticle) {
    if (bizArticle == null) {
      return null;
    }
    return new VBlog()
        .setId(bizArticle.getId())
        .setTitle(bizArticle.getTitle())
        .setCoverImage(bizArticle.getCoverImage())
        .setContent(bizArticle.getContent())
        .setContentMd(bizArticle.getContentMd())
        .setTop(bizArticle.getTop())
        .setTypeId(bizArticle.getTypeId())
        .setStatus(bizArticle.getStatus())
        .setRecommended(bizArticle.getRecommended())
        .setOriginal(bizArticle.getOriginal())
        .setDescription(bizArticle.getDescription())
        .setKeywords(bizArticle.getKeywords())
        .setComment(bizArticle.getComment())
        .setCreateTime(bizArticle.getCreateTime())
        .setUpdateTime(bizArticle.getUpdateTime());
  }
}
